const MovieHttp = require("../../models/MovieHttp")
Page({
  data:{
    movie:{}
  },
  onLoad:function(options){
    this.getMovieHttp()
  },
  async getMovieHttp(){
    var movie = {};
    var https = [{"top250":"top250"},{"inTheaters":"正在热映"},{"comingSoon":"即将上映"}];
    for(var item of https){
      var key = Object.keys(item);
      var result = await MovieHttp.getMovie(key)
      movie[key] = {
        res:result.data.res.slice(0,3),
        title:item[key]
      }
    }
    this.setData({movie})
  },
  handleMore(event){
    var {mkey} = event.currentTarget.dataset;
    wx.navigateTo({
      url: `/pages/movieDetail/movieDetail?m=${mkey}`,
    })
  }
})